﻿<UserControl x:Class="MainGameModule.Views.ChatView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:System="clr-namespace:System;assembly=mscorlib"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">

    <UserControl.Resources>
        <ResourceDictionary>

            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/YourWorld.Common;component/Styles/CommonResourcesDictionary.xaml" />
            </ResourceDictionary.MergedDictionaries>
            
            <Style x:Key="NoSelectionListBoxItem"
                   TargetType="ListBoxItem">
                <Setter Property="Padding"
                        Value="3" />
                <Setter Property="HorizontalContentAlignment"
                        Value="Left" />
                <Setter Property="VerticalContentAlignment"
                        Value="Top" />
                <Setter Property="Background"
                        Value="Transparent" />
                <Setter Property="BorderThickness"
                        Value="1" />
                <Setter Property="TabNavigation"
                        Value="Local" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="ListBoxItem">
                            <Grid Background="{TemplateBinding Background}">
                                <ContentPresenter x:Name="contentPresenter"
                                                  ContentTemplate="{TemplateBinding ContentTemplate}"
                                                  Content="{TemplateBinding Content}"
                                                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                  Margin="{TemplateBinding Padding}" />
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            
        </ResourceDictionary>
    </UserControl.Resources>

    <Grid x:Name="LayoutRoot"
          Background="Transparent">
               
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>

        <Grid x:Name="ChatPanel"
		
              Background="Transparent" Visibility="Collapsed">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            
            <ScrollViewer Grid.Column="1"
                          Name="MainScroll"
                          Height="200"
                          Margin="30 10 30 10"
                          Width="250"
                          Opacity="0.755"
                          Background="#FF10893E"
                          BorderThickness="0"
                          Style="{StaticResource ListBoxScrollViewerStyle}"
                          ScrollViewer.VerticalScrollBarVisibility="Auto"
                          ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                          HorizontalAlignment="Stretch"
                          VerticalAlignment="Stretch">
                <ListBox x:Name="History"
                         ItemsSource="{Binding Messages}"
                         ItemContainerStyle="{StaticResource NoSelectionListBoxItem}"
                         Background="White"
                         LayoutUpdated="History_LayoutUpdated">
                    <ListBox.ItemsPanel>
                        <ItemsPanelTemplate>
                            <StackPanel Orientation="Vertical" />
                        </ItemsPanelTemplate>
                    </ListBox.ItemsPanel>
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>
                                <StackPanel Orientation="Horizontal"
                                            Width="190">
                                    <TextBlock Text="{Binding SenderName}"
                                               FontWeight="Bold" />
                                    <TextBlock Text=":"
                                               FontWeight="Bold" />
                                </StackPanel>
                                <TextBlock Text="{Binding Text}"
                                           Grid.Row="1"
                                           FontStyle="Italic"
                                           TextWrapping="Wrap"
                                           Width="190"
                                           Margin="15 0 15 0"
                                           HorizontalAlignment="Center" />
                            </Grid>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </ScrollViewer>

            <Image Source="{Binding MainGameViewModel.Player.Image}"
                   Grid.Row="1"
                   Height="70"
                   Margin="10 0 10 10" />

            <Grid Grid.Column="1"
                  Grid.Row="1"
                  Margin="0 0 10 10">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="10" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>

                <Polygon Points="10,10 0,10 10,30 10,10"
                         Fill="#FF10893E" />

                <Border Background="#FF10893E"
                        CornerRadius="7"
                        Grid.Column="1">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="4" />
                            <ColumnDefinition Width="286" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>

                        <TextBlock Text="{Binding MainGameViewModel.Player.Name}"
                                   Margin="6,2,0,2"
                                   FontFamily="Arial Black"
                                   FontSize="12"
                                   Foreground="White"
                                   Grid.Column="1" />
                        <Rectangle Margin="6,0,10,0"
                                   Grid.Row="1"
                                   Height="1"
                                   Fill="Gray"
                                   Grid.Column="1" />
                        <TextBox Margin="6,3,10,10"
                                 x:Name="MessageTextBox"
                                 Grid.Row="2"
                                 Height="40"
                                 Width="270"
                                 TextWrapping="Wrap"
                                 VerticalScrollBarVisibility="Auto"
                                 Background="#FFFAFFCB"
                                 BorderBrush="Black"
                                 KeyDown="MessageTextBox_KeyDown"
                                 Grid.Column="1" />
                    </Grid>
                </Border>
            </Grid>

        </Grid>

        <Grid HorizontalAlignment="Right"
              Grid.Column="1"
              Margin="0,0,10,2"
              VerticalAlignment="Bottom">
            
            <!--<Button x:Name="HideChatButton"
                    Visibility="Collapsed"
                    Style="{StaticResource GwButtonStyle}"
                    Content=" Hide Chat "
                    FontSize="13">                
            </Button>-->

            <Button x:Name="ShowChatButton"
                    Margin="0 0 0 10"
                    ToolTipService.ToolTip="Show chat">
                <Button.Template>
                    <ControlTemplate TargetType="Button">
                        <ContentPresenter Content="{TemplateBinding Content}" />
                    </ControlTemplate>
                </Button.Template>
                <Image Source="images/ChatIcon.png" Width="58" Height="52"/>
            </Button>
        </Grid>
    </Grid>
</UserControl>